/* implement the Bag with linked list */
var Node = require('./node');

class Bag {
    constructor() {
        this._first = null;
        this._count = 0;
    }

    add(item) {

        // add to front
        if (item === 'undefined') {
            throw Error('No Arguments');
        }
        let node = new Node();
        node.value = item;
        node.next = this._first;
        this._first = node;
        this._count++;
    }

    isEmpty() {
        return this._count === 0;
    }

    size() {
        return this._count;
    }
}

module.exports = Bag;

let a = new Bag();
a.add(1);
a.add(2);

console.log(a.size());